<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="app">
        <!-- 循环数组 -->
        <ul>
            <li v-for="(item,index) in arr">{{item}} --- {{index}}</li>
        </ul>
        数组的length是<b>{{arr.length}}</b>
        <!-- 循环数字 -->
        <ul>
            <li v-for="(item,index) in 10">{{item}} --- {{index}}</li>
        </ul>

        <button @click="appendFormAttr">添加属性</button>
        <!-- 循环对象 -->
        <ul>
            <li v-for="(item,index) in formData">{{item}} --- {{index}}</li>
        </ul>
        <!-- 循环字符串
        length -->
        <ul>
            <li v-for="(item,index) in 'hello-world' ">{{item}} --- {{index}}</li>
        </ul>
    </div>

    <script src="js/vue.js"></script>
    <script>
        let myApp = new Vue({
            el:'#app',
            data:{
                arr:['html','css','js','java','php'],
                //对象初始化
                // 对象如果第一次渲染完成后
                // 在此添加对象属性之外的键值
                // 那么不参与动态渲染
                // 解决方案使用vue自带的$set
                formData:{
                    name:'tom',
                    age:'18',
                    height:'170',
                    money:99
                }
            },
            methods:{
                appendFormAttr(){
                    //
                    this.$set(this.formData,'car','bwm')
                }
            }
        })
    </script>
</body>
</html>